<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page isELIgnored="false" %>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="/admin//admin/lib/html5shiv.js"></script>
    <script type="text/javascript" src="/admin/lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="/admin/static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="/admin/lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/style.css"/>
    <title>发现列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 客户端管理 <span
        class="c-gray en">&gt;</span> 发现管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
                                              href="javascript:location.replace(location.href);" title="刷新"><i
        class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray mt-20"><span class="l">
        <a class="btn btn-primary radius" onclick="add_Version('添加发现','/findAdmin/admin/inputAddFind')"
           href="javascript:;"><i
                class="Hui-iconfont">&#xe600;</i> 添加发现内容</a>



    </span> <span class="r">共有数据：<strong>${dataMap.size()}</strong> 条</span>
    </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
            <thead>
            <tr class="text-c">
                <th width="100">ID</th>
                <th width="100">标题</th>
                <th width="120">图片</th>
                <th width="75">浏览次数</th>
                <th width="150">发布时间</th>
                <th width="60">发布状态</th>
                <th width="120">操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach var="data" items="${dataMap}">
                <tr class="text-c">
                    <td width="80">
                        <c:if test="${data.type==true}"><a href="${data.url}">${data.id}</a></c:if>
                        <c:if test="${data.type==false}"><a
                                href="/findAdmin/admin/lookfindContents?id=${data.id}">${data.id}</a></c:if>
                    </td>
                    <td>${data.title}</td>
                    <td width="120"><img height="60" src="/findAdmin/admin/lookFindIndexImage?id=${data.id}">
                    </th>
                    <td width="75">${data.num}</td>
                    <td width="60"><fmt:formatDate value="${data.ctime}" pattern="yyyy-MM-dd HH:mm"/></td>
                    <td width="60"><c:if test="${data.state}">上线中</c:if><c:if
                            test="${data.state==false}">未上线</c:if></td>
                    <td width="120">

                        <c:if test="${data.state}"> <a title="下线" href="javascript:;" class="ml-5 contentOnline"
                                                       style="text-decoration:none" data-state="${data.state}"
                                                       data-value="${data.id}">
                            <i class="Hui-iconfont">&#xe6dd;</i></a></c:if>
                        <c:if test="${data.state==false}"><a title="上线" href="javascript:;" class="ml-5 contentOnline"
                                                             style="text-decoration:none" data-state="${data.state}"
                                                             data-value="${data.id}"
                        ><i
                                class="Hui-iconfont">&#xe6e1;</i> </a></c:if>


                        <a title="删除" href="javascript:;" class="ml-5"
                           onclick="deleteFind(this,${data.id})"
                           style="text-decoration:none">
                            <i class="Hui-iconfont">&#xe609;</i></a></td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/admin/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/admin/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/admin/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
    $('.table-sort').dataTable({});

    function add_Version(title, urls) {
        var index = layer.open({
            type: 2,
            title: title,
            content: urls
        });
        layer.full(index);
    }


    $('.contentOnline').click(function () {
        var url = '/findAdmin/admin/startFind';
        checkOnline($(this), $(this).attr('data-value'), url, $(this).attr('data-state'));
    });

    function checkOnline(obj, id, url, state) {
        layer.confirm("确定要执行该操作吗？", function (index) {
            if (state == 'true') {
                $.post(url, {id: id, state: false}, function (data) {
                    if (data.code == 200) {
                        obj.parent().prev().text("未上线");
                        obj.attr("title", "上线");
                        obj.attr('data-state', 'false');
                        obj.html('<i class="Hui-iconfont">&#xe6e1;</i>');
                        layer.msg("下线成功", {icon: 2, time: 1000});
                    }
                });
            } else {
                $.post(url, {id: id, state: true}, function (data) {
                    if (data.code == 200) {
                        obj.parent().prev().text("上线中");
                        obj.attr("title", "下线");
                        obj.attr('data-state', 'true');
                        obj.html('<i class="Hui-iconfont">&#xe6dd;</i>');
                        layer.msg("上线成功", {icon: 1, time: 1000});
                    }
                });

            }
        });

    }

    function deleteFind(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {
            $.ajax({
                type: 'POST',
                url: '/findAdmin/admin/deleteFind',
                data: {"id": id},
                dataType: 'json',
                success: function (data) {
                    if (data.code == 200) {
                        $(obj).parents("tr").remove();
                        layer.msg('已删除,请刷新!', {icon: 1, time: 1000});
                    } else {
                        layer.msg('删除评论失败!', {icon: 1, time: 1000});
                    }
                },
                error: function (data) {
                },
            });
        });

    }


</script>
</body>
</html>